import { request,DownloadFile } from "@/api/request";
// import { data } from "~/server"; // /public/serverdata.baseUrl +
const baseUrl = "web_transport/"; // 添加代理(本地在vite.config.js添加，服务器在nginx添加)

import axios from 'axios';


// get使用案例
export function getList(param) {
  return request({
    url: baseUrl + "interfce/face1",
    method: "get",
    params: param,
  });
}

// post使用案例
export function saveList(data) {
  return request({
    url: baseUrl + "interfce/face1",
    method: "post",
    data,
  });
}

// delete使用案例
export function deleteList(param) {
  return request({
    url: baseUrl + "interfce/face1",
    method: "delete",
    params: param,
  });
}


export function sentProblem1(param) {
  console.log("pe", param);

  return request({
    url: "startQuery",
    method: "get",
    params: param,
  });
}

export function startQuery(formData) {
  console.log("eoo");
  
  const fd = new FormData();
  Object.entries(formData).forEach(([key, value]) => {
    fd.append(key, value);
  });

  return request({
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    url: "startQuery",
    method: "post",
    data :fd,
  });
}

export function imageResolve(formData) {
  const fd = new FormData();
  Object.entries(formData).forEach(([key, value]) => {
    fd.append(key, value);
  });

  return request({
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    url: "imageResolve",
    method: "post",
    data :fd,
  });
}


export function generateRendering(formData) {
  const fd = new FormData();
  Object.entries(formData).forEach(([key, value]) => {
    fd.append(key, value);
  });

  return request({
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    url: "generateRendering",
    method: "post",
    data :fd,
  });
}

export function deleteDialog(formData) {
  const fd = new FormData();
  Object.entries(formData).forEach(([key, value]) => {
    fd.append(key, value);
  });

  return request({
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    url: "deleteDialog",
    method: "post",
    data :fd,
  });
}

export function downloadFile(formData,url) {
  console.log("E123",formData,url);
  
  const fd = new FormData();
  Object.entries(formData).forEach(([key, value]) => {
    fd.append(key, value);
  });

  return DownloadFile('api/'+url,formData);
}

export function dialogList() {


  return request({
    url: "dialogList",
    method: "get",
    // params :fd,
  });
}


export function taskList(params) {
  // const fd = new FormData();
  // Object.entries(formData).forEach(([key, value]) => {
  //   fd.append(key, value);
  // });

  return request({
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    url: "taskList",
    method: "get",
    params,
  });
}

